import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '学号',
    align:"center",
    dataIndex: 'code'
   },
   {
    title: '姓名',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '部门',
    align:"center",
    dataIndex:'departmentId_dictText'
   },
   {
    title: '餐段',
    align:"center",
    dataIndex: 'mealName'
   },
   {
    title: '就餐日',
    align:"center",
    dataIndex: 'diningDay',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '订餐状态',
    align:"center",
    dataIndex: 'status',
    customRender: ({ text }) => {
      return render.renderDict(text, 'dining_status');
    },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
      {
        label: "学号",
        field: 'code',
        component: 'Input',
        //colProps: {span: 6},
    },
    {
      label: "姓名",
      field: 'name',
      component: 'Input',
      //colProps: {span: 6},
    },
    {
    label:"所属部门",
    component:"JSelectDept",
    field:"departmentId",
    componentProps:{
      checkStrictly:false,
      multiple:false
    }
    },
     {
      label: "就餐日",
      field: "diningDay",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
          format:'YYYY-MM-DD',
        //返回值格式化（绑定值的格式）
          valueFormat:'YYYY-MM-DD'
      },
      //colProps: {span: 6},
	},
	{
      label: "订餐状态",
      field: 'status',
      component: 'JDictSelectTag',
      componentProps:{
        dictCode:"dining_status",
        stringToNumber: true,
      },
      //colProps: {span: 6},
 	},
];


//审批查询数据
export const searchApplyForFormSchema: FormSchema[] = [
  {
    label: "学号",
    field: 'code',
    component: 'Input',
    //colProps: {span: 6},
},
{
  label: "姓名",
  field: 'name',
  component: 'Input',
  //colProps: {span: 6},
},
{
label:"所属部门",
component:"JSelectDept",
field:"departmentId",
componentProps:{
  checkStrictly:false,
  multiple:false
}
},
 {
  label: "就餐日",
  field: "diningDay",
  component: 'RangePicker',
  componentProps: {
      valueType: 'Date',
      format:'YYYY-MM-DD',
    //返回值格式化（绑定值的格式）
      valueFormat:'YYYY-MM-DD'
  }
  //colProps: {span: 6},
}
];

//表单数据
export const formSchema: FormSchema[] = [
 
  {
    label: '餐段',
    field: 'productId',
    component: 'JDictSelectTag',
    componentProps: {
      //字典code配置，比如通过性别字典编码：sex，也可以使用demo,name,id 表名,名称,值的方式
      dictCode:"cs_meals_product ,meal_name ,id, status='1'",
      //支持radio(单选按钮)、radioButton(单选按钮 btn风格)、select(下拉框)
      type:'select',
      mode:'multiple',
    },
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择餐段!'},
      ];
 },
  },
  {
    label: '就餐日',
    field: 'diningDay',
    component: 'DatePicker',
    componentProps:{
      format:'YYYY-MM-DD',
        //返回值格式化（绑定值的格式）
      valueFormat:'YYYY-MM-DD'
    },
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择就餐日!'},
      ];
    },
  },
  {
      label:"所属部门",
      component:"JSelectDept",
      field:"departmentId",
      componentProps:{
        checkStrictly:false,
        multiple:false
      }
      }, 
  {
      label: '人员',
      field: 'personId',
      component: 'JSearchSelect',
      componentProps: ({ formModel, formActionType }) => {  //formModel, formActionType
        return {
          dict:"ss_person where status != 0,name,id",
          pageSize: 5,
          async: true,
          placeholder:'请输入人员姓名'
        }      
      }  
    },
    
];

// 高级查询数据
export const superQuerySchema = {
  createTime: {title: '创建日期',order: 0,view: 'datetime', type: 'string',},
  updateTime: {title: '更新日期',order: 1,view: 'datetime', type: 'string',},
  personId: {title: '人员id',order: 2,view: 'text', type: 'string',},
  productId: {title: '餐段id',order: 3,view: 'text', type: 'string',},
  diningDay: {title: '就餐日',order: 4,view: 'date', type: 'string',},
  status: {title: '订餐状态',order: 5,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}